In technical fields such as computer science, caching techniques are often used to provide relatively low-latency access to data. For example, hardware caches on modern computer processors store fixed amounts of data that can be accessed via data writes or reads very quickly. When the cache is not available (e.g., data is not in the cache, the cache or portion thereof is locked, etc.) relatively slower operations can be used instead. For example, instead of using reading or writing to the cache, operations such as reading or writing to main memory (e.g., RAM) or storage (e.g., a hard drive) can be performed instead.
The concept of caching can also be implemented in software. For example, data structures such as hash tables, linked lists, or trees can be used to store computed data values so that future requests for these data values do not involve recomputing the data values. Instead of recomputing the data values, lookup operations into a software cache can be used to retrieve the data from the software cache.
Various techniques have been used to ensure data consistency in hardware and software caches, but these techniques tend to have certain drawbacks. For example, some techniques use relatively heavyweight locking mechanisms to restrict access to a cache or portions thereof, e.g., to ensure cache consistency when two threads attempt to access the same cache data. Other techniques may dedicate portions of a cache to a particular thread or process over an extended execution timeframe, but these techniques often result in redundant caching of data.